package com.astn.adapter.booking;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.astn.bks.R;
import com.astn.entity.booking.NameValueHolder;
import com.astn.entity.booking.QuoteBed;
import com.astn.entity.booking.QuoteFacility;

public class PFacilityAdapter extends BaseAdapter {
	private ArrayList<QuoteFacility> lstItems = new ArrayList<QuoteFacility>();
	private Context context;
	LayoutInflater oInflater;

	public PFacilityAdapter(Context context, ArrayList<QuoteFacility> lstItems) {
		this.context = context;
		this.lstItems = lstItems;
		oInflater = LayoutInflater.from(this.context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lstItems.size() + 1;
	}

	@Override
	public QuoteFacility getItem(int position) {
		if (position > 0) {
			return lstItems.get(position - 1);
		}
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0L;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		NameValueHolder holder;
		if (convertView == null) {
			if (position > 0) {
				convertView = oInflater.inflate(R.layout.facilityitem, null);
				holder = new NameValueHolder();
				holder.txvName = (TextView) convertView
						.findViewById(R.id.txvName);
				// holder.txvValue = (TextView) convertView
				// .findViewById(R.id.txvValue);

				// holder.status.
				convertView.setTag(holder);
			} else {
				holder = new NameValueHolder();
				convertView = oInflater.inflate(R.layout.firstitem, null);
				convertView.setTag(holder);
			}
		} else {
			holder = (NameValueHolder) convertView.getTag();
		}
		if (position > 0) {
			try {
				holder.txvName.setText(lstItems.get(position - 1).getName());
				// holder.txvValue.setText("");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		// holder.txvValue.setText(lstItems.get(position).getQuantity());
		// holder.txvInfo.setText(lstItems.get(position).getCountryid());
		return convertView;
	}

	@Override
	public int getItemViewType(int position) {
		if (position == 0) {
			return 0;
		}
		return 1;
	}

	@Override
	public int getViewTypeCount() {
		return 2;
	}

}
